<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>九宫格</title>
    <style>
        /* 通用样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: Arial, sans-serif;
        }
        
        /* 顶部样式 */
        #header {
            display: flex;
            justify-content: center; 
            align-items: center;
            background-color: #333;
            color: #FFFFFF;
            padding: 10px 0; 
        }
        
        #logo {
            cursor: pointer;
            font-size: 24px;
            font-weight: bold;
            padding: 10px 20px; 
        }
        
        #menu {
            display: flex;
            list-style-type: none;
        }
        
        #menu li {
            margin: 0 10px; 
            cursor: pointer;
            padding: 10px 15px;
            transition: all 0.3s;
        }
        
        #menu li:hover {
            color: #F0AD4E;
            background-color: rgba(255,255,255,0.1);
        }
        
        
        @media (max-width: 768px) {
            #header {
                flex-direction: column;
            }
            
            #menu {
                flex-wrap: wrap;
                justify-content: center;
                margin-top: 10px;
            }
            
            #menu li {
                margin: 5px;
            }
        }
    
        /* 登录页面样式 */
        #loginContainer {
            display: none;
            max-width: 400px; 
            margin: 30px auto;
        }

        #loginForm {
            padding: 30px; 
            border: 1px solid #ddd;
            border-radius: 5px;
            background-color: #f9f9f9;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }

        #loginTitle {
            text-align: center;
            font-size: 28px; 
            font-weight: bold;
            margin-bottom: 25px; 
            color: #333;
        }

        #loginForm input {
            display: block;
            width: 100%;
            margin-bottom: 20px; 
            padding: 12px;
            border: 1px solid #ddd;
            border-radius: 3px;
            font-size: 16px; 
        }

        #loginForm button {
            width: 100%;
            padding: 12px; 
            background-color: #000; 
            color: #FFFFFF;
            cursor: pointer;
            border: none;
            border-radius: 3px;
            transition: background-color 0.3s;
            font-size: 16px; 
        }

        #loginForm button:hover {
            background-color: #333;
        }

        /* 首页样式 */
        #homePage {
            display: none;
            padding: 20px;
            max-width: 1200px;
            margin: 0 auto;
        }

        #homePage h1 {
            margin-bottom: 20px;
            text-align: center;
        }

        #homePage img {
            width: 100%;
            height: auto;
            margin-bottom: 20px;
            border-radius: 5px;
        }

        #homePage p {
            line-height: 1.6;
            text-align: center;
        }
    </style>
</head>
<body>
    <!-- 顶部 -->
    <header id="header">
        <span id="logo"> WHITE</span>
        <ul id="menu">
            <li>首页</li>
            <li>关于</li>
            <li>照片集</li>
            <li>服务</li>
            <li>微博</li>
            <li>联系</li>
            <li id="loginMenuItem">登录</li>
        </ul>
    </header>
    
    <!-- 登录页面 -->
       <!-- 登录容器 -->
    <div id="loginContainer">
        <form id="loginForm">
            <div id="loginTitle">登录</div>
            <input type="text" name="username" id="username" placeholder="账号">
            <input type="password" name="password" id="password" placeholder="密码">
            <button type="button" onclick="login()">登录</button>
        </form>
    </div>

    <!--首页内容-->
    <p align="center"><img src="15.jpg" height="800" width="100%"></p>
    <p align="center"><img src="project1.jpg" height="200" width="200"> <img src="m-project2.jpg" height="200" width="200">
      <img src="project2.jpg" height="200" width="200"></p> <p align="center"><img src="m-project1.jpg" height="300" width="200">
      <img src="project4.jpg" height="200" width="200"><img src="m-project3.jpg" height="300" width="200"></p>
      <p align="center"><img src="project5.jpg" height="200" width="200"><img src="project6.jpg" height="200" width="200">
      <img src="project7.jpg" height="200" width="200"></p>
    </div>
    <script>
        // 为菜单中的登录菜单项添加点击事件
        document.getElementById('loginMenuItem').addEventListener('click', function() {
            toggleLoginForm();
        });

        // 顶部点击事件
        document.getElementById('logo').addEventListener('click', function() {
            showHomePage();
        });

        // 为菜单项添加点击事件，用于页面导航
        document.querySelectorAll('#menu li:not(#loginMenuItem)').forEach(item => {
            item.addEventListener('click', function() {
                alert('该功能尚未实现');
            });
        });

        // 登录功能
        function login() {
            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;
            if (username === '') {
                alert('账号不能为空');
                return;
            }
            if (password === '') {
                alert('密码不能为空');
                return;
            }
            if (username.length < 3) {
                alert('账号长度少于3位');
                return;
            }
            if (password.length < 6) {
                alert('密码长度少于6位');
                return;
            }
            if (username === 'admin' && password === '123456') {
                showHomePage();
                alert('登录成功！欢迎回来，admin');
            } else {
                alert('账号或密码错误');
            }
        }

        // 切换登录表单显示状态
        function toggleLoginForm() {
            const loginContainer = document.getElementById('loginContainer');
            const homePage = document.getElementById('homePage');
            
            if (loginContainer.style.display === 'none') {
                loginContainer.style.display = 'block';
                homePage.style.display = 'none';
            } else {
                loginContainer.style.display = 'none';
            }
        }

        // 显示首页
        function showHomePage() {
            document.getElementById('loginContainer').style.display = 'none';
            document.getElementById('homePage').style.display = 'block';
        }

        // 初始化显示首页
        document.addEventListener('DOMContentLoaded', function() {
            showHomePage();
        });
    </script>
</body>
</html>